package com.ruoyi.web.controller.comlbs;


import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.JSONObjectPro;
import com.ruoyi.system.domain.DriverInfo;
import com.ruoyi.system.service.IDriverInfoService;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.stream.Collectors;

/**
 * 指令下发选项Controller
 * 
 * @author wp
 * @date 2023-08-10
 */
@RestController
@RequestMapping("/comlbs/orderSelectList")
public class OrderListController extends BaseController {

    @Autowired
    private IDriverInfoService driverInfoService;

    @ApiOperation("负责人列表")
    @GetMapping("/getDriverList")
    public AjaxResult getConfigList() {
        List<DriverInfo> list = driverInfoService.selectList(new DriverInfo())
                .stream().filter(d -> CollectionUtils.isNotEmpty(d.getPicture())).collect(Collectors.toList());
        List<JSONObjectPro> collect = list.stream().map(driver -> new JSONObjectPro()
                .put("label", driver.getName())
                .put("value", driver.getId())
                .put("id", driver.getId())).collect(Collectors.toList());
        return success(collect);
    }
}
